<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/1/3
  Time: 22:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>

    <script src="js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"/>
    <script>
        var isFind=false;//代表名称是否重复
    /*    $(document).ready(function(){
            $("#name").blur(function(){
                $.ajax(
                    {
                        "url":"addServlet",
                        "data":"opr=CheckName&name="+$("#name").val(),
                        "dataType":"text",
                        "success":function(data){
                            if(data=="ok"){
                                isFind=false;//不重复
                            }else if(data=="no"){
                                isFind=true;//重复
                            }
                        }
                    }
                );
            });
        });*/

        //验证名称重复
        /* */

        function checkMsg(){

            var reg=/^[1-9]\d*$|^0$/;
            if(!reg.test($("#bookPages").val())){
                alert("不是整数！");
                return false;
            }

            $("input[type=text]").each(function(i){
                var text = $(this).val();
                if(text ==""){
                    alert("有空值");
                    return false;
                }
                if(isNan($("#bookPrice").val())){
                    return false;
                }
            });

            return true;
        }
    </script>

</head>
<body>
<h3>增加新书</h3>
<form action="book/add" method="post" onsubmit=" return checkMsg()">
    书名:  <input name="bookName"/><br/>
    作者: <input type="text" name="bookAuthor" /><br/>
    出版社: <input type="text" name="bookPublish" /><br/>
    页数: <input type="text" name="bookPage" id="bookPages"/><br/>
    价格: <input type="text" name="bookPrice" id="bookPrice"/><br/>

    <input type="submit" value="提交"/>
    <input type="reset" value="重置"/>
</form>
</body>
</html>
